package com.wwf.myblog.controller;

import com.wwf.myblog.pojo.Article;
import com.wwf.myblog.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @Autowired
    IArticleService articleService;

    /*@RequestMapping("demo")
    public Map<String,Object> Index(){
        HashMap<String, Object> stingObjectHashMap = new HashMap<String, Object>();
        stingObjectHashMap.put("id",123);
        stingObjectHashMap.put("username","ewewewewe1456");
        return stingObjectHashMap;
    }*/
    @RequestMapping("index/{pagenum}/{pagesize}")
    public String myblogIndex(@PathVariable Integer pagenum, @PathVariable Integer pagesize, Model module){
        Page<Article> articles = articleService.pageAllArticles(pagesize, pagenum);
        module.addAttribute("page",articles);
        module.addAttribute("pagenum",pagenum);
        return "client/index";
    }

}
